<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2018-02-26 14:03:35 apple $
 * 记录日志
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['thiss']=array(
	'1'=>'管理端',
	'2'=>'客户端',
);
$return['ostitle']=get_ostitle();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array();
	if(isset($_RQ['uniacid'])){
		$params['uniacid']=intval($_RQ['uniacid']);
		$return['params']['uniacid']=$_RQ['uniacid'];
	}
	if(isset($_RQ['uid'])){
		$params['uid']=intval($_RQ['uid']);
		$return['params']['uid']=$_RQ['uid'];
	}
	if($_RQ['this']){
		$params['this']=$_RQ['this'];
		$return['params']['this']=$_RQ['this'];
	}
	if(isset($_RQ['os'])){
		$params['os']=intval($_RQ['os']);
		$return['params']['os']=$_RQ['os'];
	}
	if($_RQ['remark']){
		$params['remark like']='%'.trim($_RQ['remark']).'%';
		$return['params']['remark']=$_RQ['remark'];
	}
    $orderby='id desc';
	$total='';
	$list=pdo_getslice('core_oper_log',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	if($list){
		foreach($list as &$item){
			if(!$item['plugin'] || $item['plugin']=='core'){
				$item['plugintitle']='系统';
			}else{
				$item['plugintitle']=pdo_getcolumn('core_plugins',array('name'=>$item['plugin']),'title');
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'日志列表'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'id','title'=>'记录ID','type'=>'string'),
			array('name'=>'uniacid','title'=>'站点ID','type'=>'string'),
			array('name'=>'uid','title'=>'账号ID','type'=>'string'),
			array('name'=>'this','title'=>'前后端','type'=>'radio','options'=>'thiss'),
			array('name'=>'os','title'=>'来源','type'=>'radio','options'=>'ostitle'),
			array('name'=>'plugintitle','title'=>'所属插件','type'=>'string'),
			array('name'=>'action','title'=>'页面','type'=>'string'),
			array('name'=>'op','title'=>'OP','type'=>'string'),
			array('name'=>'remark','title'=>'备注','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'uniacid','width'=>10,'title'=>'站点ID','type'=>'string'),
			array('name'=>'uid','width'=>10,'title'=>'账号ID','type'=>'string'),
			array('name'=>'this','width'=>10,'title'=>'前后端','type'=>'radio','options'=>'thiss'),
			array('name'=>'os','width'=>10,'title'=>'来源','type'=>'radio','options'=>'ostitle'),
			array('name'=>'plugintitle','width'=>10,'title'=>'所属插件','type'=>'string'),
		),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('core_oper_log',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('core_oper_log',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}

?>